package lifeng.design.command;

public class FanOnCommand implements Command
{
	private Fan fan;
	private boolean change;
	
	public FanOnCommand(Fan f)
	{
		change = false;
		fan = f;
	}
	
	
	public void execute()
	{
		if ("off".equals(fan.getState()))
		{
			change = true;
			fan.startRotate();
		}
		else 
		{
			change = false;
			System.out.println("The fan has been start! No action");
		}
	}
	
	public void unExecute()
	{
		if (change)
		{
			fan.stopRotate();
			System.out.println("-->from undo command");
		}
		else
		{
			System.out.println("The fan has been started! Undo nothing");
		}
	}
}
